package de.jmda.gen.java.impl;

import static org.junit.Assert.assertTrue;

import org.apache.log4j.Logger;
import org.junit.Test;

import de.jmda.gen.Generator;
import de.jmda.gen.GeneratorException;

public class JUT_DefaultImportStatementGenerator
{
	private final static Logger LOGGER =
      Logger.getLogger(JUT_DefaultImportStatementGenerator.class);

	@Test
	public void testDefaultImportStatementGeneratorString()
			throws GeneratorException
	{
		String input = "import Test;";

		Generator generator = new DefaultImportStatementGenerator(input);
		
		StringBuffer generated = generator.generate();

		LOGGER.debug("generated [" + generated + "]");

		assertTrue(
				"unexpected import statement [" + generated + "]",
				input.contentEquals(generated));
	}

	@Test
	public void testInvalidMissingPrefixDefaultImportStatementGeneratorString()
			throws GeneratorException
	{
		// missing prefix 'import '
		String input = "Test;";

		Generator generator = new DefaultImportStatementGenerator(input);
		
		StringBuffer generated = generator.generate();

		LOGGER.debug("generated [" + generated + "]");

		assertTrue(
				"unexpected import statement [" + generated + "]",
				("import " + input).contentEquals(generated));
	}

	@Test
	public void testInvalidMissingSuffixDefaultImportStatementGeneratorString()
			throws GeneratorException
	{
		// missing suffix ';'
		String input = "import Test";

		Generator generator = new DefaultImportStatementGenerator(input);
		
		StringBuffer generated = generator.generate();

		LOGGER.debug("generated [" + generated + "]");

		assertTrue(
				"unexpected import statement [" + generated + "]",
				(input + ";").contentEquals(generated));
	}
}